package xidian.vlab.domin;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.dialect.Teradata14Dialect;
import xidian.vlab.domin.User.Teacher;

import javax.persistence.*;
import java.util.*;

@Entity
public class Room {
    @Id
    private String rid;
    private Long cid;
    private String name;
    private String status;
    private String profile;
    private Date createTime;
    private Date updateTime;
    private Date endTime;

    @OneToMany(mappedBy = "room", cascade = CascadeType.ALL)
    private List<VMachine> machines = new ArrayList<>();

    @ManyToOne(targetEntity = Teacher.class)
    @JoinColumn(name = "tid")
    private Teacher teacher;


    //////////////////////////////////////////////////////
    public Room(){}
    public Room(String rid,Long cid, String name, String status, String profile, Date createTime, Date updateTime, Date endTime, Teacher teacher) {
        this.rid = rid;
        this.cid = cid;
        this.name = name;
        this.status = status;
        this.profile = profile;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.endTime = endTime;
        this.teacher = teacher;
    }

    public String getRid() {
        return rid;
    }

    public void setRid(String rid) {
        this.rid = rid;
    }

    public Long getCid() {
        return cid;
    }

    public void setCid(Long cid) {
        this.cid = cid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getProfile() {
        return profile;
    }

    public void setProfile(String profile) {
        this.profile = profile;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public List<VMachine> getMachines() {
        return machines;
    }

    public void setMachines(List<VMachine> machines) {
        this.machines = machines;
    }

    public Teacher getTeacher() {
        return teacher;
    }

    public void setTeacher(Teacher teacher) {
        this.teacher = teacher;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    @Override
    public String toString() {
        return "Room{" +
                "rid=" + rid +
                ", name='" + name + '\'' +
                ", status=" + status +
                ", profile='" + profile + '\'' +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", machines.size=" + machines.size() +
                ", teacherId=" + teacher.getTid() +
                '}';
    }
}
